# $Id$
# Maintainer:
# Contributor: damir <damir@archlinux.org>

pkgname=libcdio
pkgver=0.94
pkgrel=2
pkgdesc="GNU Compact Disc Input and Control Library"
arch=('i686' 'x86_64')
license=('GPL3')
url="https://www.gnu.org/software/libcdio/"
depends=('libcddb' 'ncurses' 'gcc-libs')
source=(https://ftp.gnu.org/gnu/libcdio/${pkgname}-${pkgver}.tar.gz{,.sig}
        libcdio-0.83-linking.patch)
sha256sums=('96e2c903f866ae96f9f5b9048fa32db0921464a2286f5b586c0f02699710025a'
            'SKIP'
            'd88186b2a11726fe5ef10853e0245996b55793552b14230d1f7ba5ee3c54f3ed')
validpgpkeys=('DAA63BC2582034A02B923D521A8DE5008275EC21') # R. Bernstein

prepare() {
  cd ${pkgname}-${pkgver}
  patch -Np1 -i ../libcdio-0.83-linking.patch

  # Unbreak symbol versioning
  # https://savannah.gnu.org/bugs/?49907
  sed -i '/AM_INIT_AUTOMAKE/s/subdir-objects//' configure.ac

  autoreconf -fi
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr --disable-vcd-info --enable-cpp-progs --disable-static
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make -j1 DESTDIR="${pkgdir}" install
  
  sed -i "/LIBCDIO_SOURCE_PATH/s|.*|/* #undef LIBCDIO_SOURCE_PATH */|" \
    $pkgdir/usr/include/cdio/cdio_config.h
}
